setwd("/home/jr/Bureau/")
setwd("/home/jr/Documents/INRA/article-detection-noeuds-aubier/img/histogramme/")

hist1 = read.table("histvalues.txt")
hist2 = read.table("hist2values.txt")
names(hist1) <- (c("x", "y"))
names(hist2) <- (c("x", "y"))


pdf("histogramme.pdf")
plot(hist1$x, hist1$y, type="l", col="blue", xlab="Radius (mm)", ylab="Hounsfield units (HU)", ylim=c(min(hist1$y, hist2$y), max(hist1$y, hist2$y)+50))
lines(hist2$x, hist2$y, type="l", col="red", lty=3, lwd=2)

#abline(-250,0, col="grey40")

text(c(max(hist1[hist1$y == max(hist1$y), "x"]), 18.5, 16), c(max(hist1$y), -140, 30),  c("A", "B", "C"), pos=3,)
points(c(max(hist1[hist1$y == max(hist1$y), "x"]), 18.5, 16), c(max(hist1$y), -140, 30), pch=20, col="blue")

text(c(max(hist2[hist2$y == max(hist2$y), "x"]), 23, 13), c(max(hist2$y), -450, -73),  c("A", "B", "C"), pos=3,)
points(c(max(hist2[hist2$y == max(hist2$y), "x"]), 23, 12.5), c(max(hist2$y), -450 , -73), pch=20, col="red")

legend("topright", pch="", col = c("blue", "red") , legend = c("Sapwood", "Heartwood"), lty=c(1,3), lwd=c(1,3), bty="n")
dev.off()
